<html xmlns:th="http://www.thymeleaf.org">
<div class="bjui-pageHeader" style="background-color:#fefefe; border-bottom:none;">
    <form data-toggle="ajaxsearch"
          data-options="{searchDatagrid:$.CurrentNavtab.find('#datagrid-deviceVirtual-filter')}">
        <div class="bjui-searchBar">
            <label>客户端名：</label>
            <input type="text" name="clientName" class="form-control" size="15">
            <label>虚拟机名：</label>
            <input type="text" name="virtualName" class="form-control" size="15">
            <label>虚拟机mac：</label>
            <input type="text" name="virtualMac" class="form-control" size="15">


            <button type="button" class="btn showMoreSearch" data-toggle="moresearch" data-name="custom" title="更多查询条件">
                <i class="fa fa-angle-double-up"></i></button>

            <button type="submit" class="btn-green" data-icon="search">搜索</button>
            <button type="reset" class="btn-orange" data-icon="times" onclick="resetAll();">重置</button>

            <div class="bjui-moreSearch" style="top: 27px; display: none;">
                <label>当前任务</label>
                <select name="taskCmd" data-toggle="selectpicker" id="selectCurrentTask">
                </select>
                <label>任务状态</label>
                <select name="taskState" data-toggle="selectpicker" id="selectCurrentTaskState">
                </select>
                <label>状态</label>
                <select name="state" data-toggle="selectpicker" id="select_client_state">
                </select>

            </div>
        </div>
    </form>
</div>
<div class="bjui-pageContent">
    <table class="table table-bordered" id="datagrid-deviceVirtual-filter" data-toggle="datagrid" data-options="{
        height: '100%',
        showToolbar: true,
        toolbarItem: 'refresh,|,add,edit,del',
        dataUrl: '/admin/virtual',
        dataType: 'json',
        jsonPrefix: '',
        editMode: {dialog:{width:'700',height:750,title:'编辑信息',mask:true}},
        editUrl: '/admin/virtual/initpage?req_id={id}',
        delUrl:'/admin/virtual/del',
        delPK:'id',
        delConfirm:true,
        showCheckboxcol: true,
        inlineEditMult:false,
        paging: {pageSize:20},
        linenumberAll: true,
        filterThead:false,
        hScrollbar:true
    }">
        <thead>
        <tr>
            <th data-options="{name:'id',align:'center',width:150,render:showOpButton}">操作</th>
            <th data-options="{name:'deviceClient.name',align:'center',width:150}">客户端</th>
            <th data-options="{name:'virtualName',align:'center',width:150}">虚拟机名</th>
            <th data-options="{name:'virtualMac',align:'center',width:115}">虚拟机mac</th>
            <th data-options="{name:'taskCmd',align:'center',width:150}">任务命令</th>
            <th data-options="{name:'taskState',align:'center',width:170}">任务状态</th>
            <th data-options="{name:'state',align:'center',width:50}">状态</th>
            <th data-options="{name:'remark',align:'center',width:150}">备注</th>
            <th data-options="{name:'updatedTime',align:'center',width:170}">更新时间</th>
        </tr>
        </thead>
    </table>
</div>
<script type="text/javascript">
    select_option('select_client_state', 'com.imessage.type.DeviceVirtualState');
    select_option('selectCurrentTask', 'com.imessage.type.BusinessTaskCmd');
    select_option('selectCurrentTaskState', 'com.imessage.type.BusinessTaskState');
    function showOpButton(value,data) {
        var html="";
        if(data.state=="运行"){
            html+="<button type=\"button\" class=\"btn-green\" data-toggle=\"doajax\" data-options=\"{id:'addetail', url:'/admin/virtual/state?state=shutdown&id="+value+"', title:'关机'}\">关机</button>";
        }
        if(data.state=="关机"){
            html+="<button type=\"button\" class=\"btn-green\" data-toggle=\"doajax\" data-options=\"{id:'addetail', url:'/admin/virtual/state?state=start&id="+value+"', title:'启动'}\">启动</button>";
        }
        html+="<button type=\"button\" class=\"btn-green\" data-toggle=\"doajax\" data-options=\"{id:'addetail', url:'/admin/virtual/state?state=restart&id="+value+"', title:'重启'}\">重启</button>";
        html+="<button type=\"button\" class=\"btn-green\" data-toggle=\"doajax\" data-options=\"{id:'addetail', url:'/admin/virtual/state?state=shutdown&id="+value+"', title:'关机'}\">关机</button>";
        return html;
    }
</script>
